__author__ = "Alexandre Lessard"
__copyright__ = "Copyright 2011, Alexandre Lessard"
__credits__ = ["Alexandre Lessard"]
__license__ = "BSD"
__version__ = "0.0.1"
__maintainer__ = "Alexandre Lessard"
__email__ = "alexandre.lessard.ti@gmail.com"
__status__ = "Prototype"

"""Class for the factory system module.
It's used to load other modules on demande,  init the contructor
and return the object."""


class Factory_wrapper:
    """Wrapper made to call factory method as
    static methods"""
    def __init__(self, anycallable):
        self.__call__ = anycallable

# toy-example usage:
class Factory:
    def model(name):
        """To autoload the models
        from name and return the class"""
        
        classname = name.capitalize()+"Model"
        tmpModel = __import__("simpleAppsSME.models."+name, globals(), \
                              locals(), [classname], -1)
        return  getattr(tmpModel, classname)()
    model = Factory_wrapper(model)
